let mans = document.querySelector(".man");
let womans = document.querySelector(".woman");
let cmsa = document.querySelector("#cms");
let kgsa = document.querySelector("#kgs");
let agesa = document.querySelector("#ages");
let btn = document.querySelector(".btn");
let lu = document.querySelector(".lu");
let changes = document.querySelector(".changes");
let canzhao = document.querySelector(".canzhao")
let hk = document.querySelector(".hk");
let pian = document.querySelector(".pian");
let sex = document.querySelector(".sex");
let biao = document.querySelector(".biao");
let kaos = document.querySelector(".kaos");
let jixu = document.querySelector(".jixu");
let hom = document.querySelector(".hom");
let hos = document.querySelector(".hos");
let shuai = document.querySelector(".shuai");
let mei = document.querySelector(".mei");
let shuais = document.querySelector(".shuais");
let meis = document.querySelector(".meis");
let index = 0;
let bb = document.querySelector(".bb");
let aa = document.querySelector(".aa");
let ab = document.querySelector(".ab");
let ac = document.querySelector(".ac");
let ad = document.querySelector(".ad");
let ae = document.querySelector(".ae");
let af = document.querySelector(".af");
let ag = document.querySelector(".ag");
let ah = document.querySelector(".ah");
let ai = document.querySelector(".ai");
let dad = document.querySelectorAll(".dad");
let mya = document.querySelector(".mya");
let myb = document.querySelector(".myb");
let myc = document.querySelector(".myc");

// 导入当前时间
var datess = new Date();
var year1 = datess.getFullYear();
var month1 = datess.getMonth() + 1;
var date1 = datess.getDate();

mans.addEventListener("click", function () {
    index = 1;
    sex.style.display = "none";
    biao.style.display = "block";
    hos.style.display = "block";
    shuai.style.display = "block";
})

womans.addEventListener("click", function () {
    index = 2;
    sex.style.display = "none";
    biao.style.display = "block";
    hos.style.display = "block";
    mei.style.display = "block";
})

function getDate() {
    let data = localStorage.getItem('man');
    if (data !== null) {
        return JSON.parse(data);
    } else {
        return [];
    }
}

function savaDate(local) {
    localStorage.setItem('man', JSON.stringify(local));
}

function getDates() {
    let data = localStorage.getItem('woman');
    if (data !== null) {
        return JSON.parse(data);
    } else {
        return [];
    }
}

function savaDates(local) {
    localStorage.setItem('woman', JSON.stringify(local));
}

btn.addEventListener("click", function () {
    let cms = cmsa.value;
    let kgs = kgsa.value;
    let ages = agesa.value;
    if (cms == "" || kgs == "" || ages == "") {
        alert("请补全信息");
    } else if (140 < cms && cms < 200 && 30 < kgs && kgs < 110 && 17 < ages && ages < 99) {
        hk.style.display = "block";
        hos.style.display = "none";
        let bmis = kgs / (cms / 100 * cms / 100);
        let bmi = bmis.toFixed(2);
        //判断男女
        if (index == 1) {
            let sums = 1.2 * bmi + 0.23 * ages - 5.4 - 10.8 * 1;
            let sum = Math.round(sums);
            let dates = getDate();
            let dtss = month1 + "." + date1;
            let local = getDate();
            local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
            savaDate(local);
            if (dates.length == 0) {
                let local = getDate();
                local.push({ dts: 1.1, cm: 170, kg: 60, num: 13 });
                local.push({ dts: 1.2, cm: 175, kg: 75, num: 16 });
                local.push({ dts: 1.3, cm: 180, kg: 70, num: 14 });
                local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
                savaDate(local);
            }
            if (dates.length == 50) {
                localStorage.removeItem("man");
                let local = getDate();
                local.push({ dts: 1.1, cm: 170, kg: 60, num: 13 });
                local.push({ dts: 1.2, cm: 175, kg: 75, num: 16 });
                local.push({ dts: 1.3, cm: 180, kg: 70, num: 14 });
                local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
                savaDate(local);
            }
            if (ages >= 18 && ages <= 39) {
                if (sum >= 5 && sum <= 10) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 11 && sum <= 16) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 17 && sum <= 21) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 22 && sum <= 26) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 27 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else if (ages >= 40 && ages <= 59) {
                if (sum >= 5 && sum <= 11) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 12 && sum <= 17) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 18 && sum <= 22) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 23 && sum <= 27) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 28 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else if (ages >= 60 && ages <= 99) {
                if (sum >= 5 && sum <= 13) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 14 && sum <= 19) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 20 && sum <= 24) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 25 && sum <= 29) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 30 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else {
                alert("不符合正常人的年龄");
            }
        } else if (index == 2) {
            let sums = 1.2 * bmi + 0.23 * ages - 5.4 - 10.8 * 0;
            let sum = Math.round(sums);
            let dates = getDates();
            let dtss = month1 + "." + date1;
            let local = getDates();
            local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
            savaDates(local);
            if (dates.length == 0) {
                let local = getDates();
                local.push({ dts: 1.1, cm: 155, kg: 50, num: 24 });
                local.push({ dts: 1.2, cm: 160, kg: 60, num: 27 });
                local.push({ dts: 1.3, cm: 170, kg: 60, num: 24 });
                local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
                savaDates(local);
            }
            if (dates.length == 50) {
                localStorage.removeItem("woman");
                let local = getDates();
                local.push({ dts: 1.1, cm: 155, kg: 50, num: 24 });
                local.push({ dts: 1.2, cm: 160, kg: 60, num: 27 });
                local.push({ dts: 1.3, cm: 170, kg: 60, num: 24 });
                local.push({ dts: dtss, cm: cms, kg: kgs, num: sum });
                savaDates(local);
            }

            if (ages >= 18 && ages <= 39) {
                if (sum >= 5 && sum <= 20) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 21 && sum <= 27) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 28 && sum <= 34) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 35 && sum <= 39) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 40 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else if (ages >= 40 && ages <= 59) {
                if (sum >= 5 && sum <= 21) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 22 && sum <= 28) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 29 && sum <= 35) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 36 && sum <= 40) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 41 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else if (ages >= 60 && ages <= 99) {
                if (sum >= 5 && sum <= 22) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏瘦型）"
                } else if (sum >= 23 && sum <= 29) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（健康型）"
                } else if (sum >= 30 && sum <= 36) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（微胖型）"
                } else if (sum >= 37 && sum <= 41) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（轻度偏胖型）"
                } else if (sum >= 42 && sum <= 45) {
                    lu.innerHTML = sum + "%";
                    pian.innerHTML = "（重度偏胖型）"
                } else {
                    alert("数据库没有记录")
                }
            } else {
                alert("不符合正常人的年龄");
            }
        } else {
            alert("你不男不女？")
        }
    } else {
        alert("非正常数据，请仔细填写！")
    }
})

changes.addEventListener("click", function () {
    cmsa.value = "";
    kgsa.value = "";
    agesa.value = "";
    lu.innerHTML = "";
    hk.style.display = "none";
    hos.style.display = "block";
})

canzhao.addEventListener("click", function () {
    biao.style.display = "none";
    shuai.style.display = "none";
    mei.style.display = "none";
    kaos.style.display = "block";
    if (index == 1) {
        shuais.style.display = "block";
        manss();
    } else if (index == 2) {
        meis.style.display = "block";
        womanss();
    }
})

jixu.addEventListener("click", function () {
    biao.style.display = "block";
    if (index == 1) {
        shuai.style.display = "block";
    } else if (index == 2) {
        mei.style.display = "block";
    }
    kaos.style.display = "none";
    shuais.style.display = "none";
    meis.style.display = "none";
})

hom.addEventListener("click", function () {
    sex.style.display = "block";
    biao.style.display = "none";
    shuai.style.display = "none";
    mei.style.display = "none";
    kaos.style.display = "none";
    shuais.style.display = "none";
    meis.style.display = "none";
    cmsa.value = "";
    kgsa.value = "";
    agesa.value = "";
    lu.innerHTML = "";
    hk.style.display = "none";
    index = 0;
})

hos.addEventListener("click", function () {
    sex.style.display = "block";
    biao.style.display = "none";
    shuai.style.display = "none";
    mei.style.display = "none";
    kaos.style.display = "none";
    shuais.style.display = "none";
    meis.style.display = "none";
    cmsa.value = "";
    kgsa.value = "";
    agesa.value = "";
    lu.innerHTML = "";
    hk.style.display = "none";
    index = 0;
})

function manss() {
    // 取本地存储值
    let dates = getDate();
    if (dates.length >= 4) {
        // 第一个
        let cad = dates.length - 1;
        bb.children[0].innerHTML = dates[cad].dts;
        bb.children[1].innerHTML = dates[cad].cm;
        bb.children[2].innerHTML = dates[cad].kg;
        bb.children[3].innerHTML = dates[cad].num;
        // 第二个
        let cac = dates.length - 2;
        ab.children[0].innerHTML = dates[cac].dts;
        ab.children[1].innerHTML = dates[cac].cm;
        ab.children[2].innerHTML = dates[cac].kg;
        ab.children[3].innerHTML = dates[cac].num;
        // 第三个
        let cab = dates.length - 3;
        ae.children[0].innerHTML = dates[cab].dts;
        ae.children[1].innerHTML = dates[cab].cm;
        ae.children[2].innerHTML = dates[cab].kg;
        ae.children[3].innerHTML = dates[cab].num;
        // 第四个
        let caa = dates.length - 4;
        ah.children[0].innerHTML = dates[caa].dts;
        ah.children[1].innerHTML = dates[caa].cm;
        ah.children[2].innerHTML = dates[caa].kg;
        ah.children[3].innerHTML = dates[caa].num;
    }

    //时间变化
    let oa = bb.children[0].innerHTML;
    let ob = ab.children[0].innerHTML;
    let oc = ae.children[0].innerHTML;
    let od = ah.children[0].innerHTML;
    let oas = oa.split('.');
    let obs = ob.split('.');
    let ocs = oc.split('.');
    let ods = od.split('.');

    for (let i = 0; i < dad.length; i++) {
        if (i == 0) {
            if (oas[0] - obs[0] == 0) {
                // 一个月内
                if (oas[1] - obs[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - obs[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[1] - obs[1] + "天前";
                } else if (oas[1] - obs[1] >= 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                } else if (oas[1] - obs[1] >= 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                } else if (oas[1] - obs[1] >= 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else if (oas[0] - obs[0] < 0) {
                dad[i].style.color = "red";
                dad[i].innerHTML = "去年";
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - obs[0] + "月前"
            }
        }
        if (i == 4) {
            if (oas[0] - ocs[0] == 0) {
                // 一个月内
                if (oas[1] - ocs[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - ocs[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[1] - ocs[1] + "天前";
                } else if (oas[1] - ocs[1] >= 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                } else if (oas[1] - ocs[1] >= 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                } else if (oas[1] - ocs[1] >= 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else if (oas[0] - ocs[0] < 0) {
                dad[i].style.color = "red";
                dad[i].innerHTML = "去年";
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - ocs[0] + "月前"
            }
        }
        if (i == 8) {
            if (oas[0] - ods[0] == 0) {
                // 一个月内
                if (oas[1] - ods[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - ods[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[1] - ods[1] + "天前";
                } else if (oas[1] - ods[1] >= 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                } else if (oas[1] - ods[1] >= 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                } else if (oas[1] - ods[1] >= 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else if (oas[0] - ods[0] < 0) {
                dad[i].style.color = "red";
                dad[i].innerHTML = "去年";
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - ods[0] + "月前";
            }
        }
    }

    // 身高变化 
    let pa = bb.children[1].innerHTML;
    let pb = ab.children[1].innerHTML;
    let pc = ae.children[1].innerHTML;
    let pd = ah.children[1].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function obb() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "black";
        }
        if (pa - pb == 0) {
            if (i == 1) {
                obb();
            }
        } else if (pa - pb > 0) {
            if (i == 1) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pb + "cm↑";
            }
        } else if (pa - pb < 0) {
            if (i == 1) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pb - pa + "cm↓";
            }
        }
        if (pa - pc == 0) {
            if (i == 5) {
                obb();
            }
        } else if (pa - pc > 0) {
            if (i == 5) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pc + "cm↑";
            }
        } else if (pa - pc < 0) {
            if (i == 5) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pc - pa + "cm↓";
            }
        }
        if (pa - pd == 0) {
            if (i == 9) {
                obb();
            }
        } else if (pa - pd > 0) {
            if (i == 9) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pd + "cm↑";
            }
        } else if (pa - pd < 0) {
            if (i == 9) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pd - pa + "cm↓";
            }
        }
    }

    // 体重变化
    let da = bb.children[2].innerHTML;
    let db = ab.children[2].innerHTML;
    let dc = ae.children[2].innerHTML;
    let dd = ah.children[2].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function occ() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "block";
        }

        if (da - db == 0) {
            if (i == 2) {
                occ();
            }
        } else if (da - db > 0) {
            if (i == 2) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - db + "kg↑";
            }
        } else if (da - db < 0) {
            if (i == 2) {
                dad[i].style.color = "green";
                dad[i].innerHTML = db - da + "kg↓";
            }
        }
        if (da - dc == 0) {
            if (i == 6) {
                occ();
            }
        } else if (da - dc > 0) {
            if (i == 6) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - dc + "kg↑";
            }
        } else if (da - dc < 0) {
            if (i == 6) {
                dad[i].style.color = "green";
                dad[i].innerHTML = dc - da + "kg↓";
            }
        }
        if (da - dd == 0) {
            if (i == 10) {
                occ();
            }
        } else if (da - dd > 0) {
            if (i == 10) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - dd + "kg↑";
            }
        } else if (da - dd < 0) {
            if (i == 10) {
                dad[i].style.color = "green";
                dad[i].innerHTML = dd - da + "kg↓";
            }
        }
    }

    // 体脂率变化
    let ra = bb.children[3].innerHTML;
    let rb = ab.children[3].innerHTML;
    let rc = ae.children[3].innerHTML;
    let rd = ah.children[3].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function odd() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "block";
        }
        if (ra - rb == 0) {
            if (i == 3) {
                odd();
            }
        } else if (ra - rb > 0) {
            if (i == 3) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rb + "%↑";
            }
        } else if (ra - rb < 0) {
            if (i == 3) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rb - ra + "%↓";
            }
        }
        if (ra - rc == 0) {
            if (i == 7) {
                odd();
            }
        } else if (ra - rc > 0) {
            if (i == 7) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rc + "%↑";
            }
        } else if (ra - rc < 0) {
            if (i == 7) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rc - ra + "%↓";
            }
        }
        if (ra - rd == 0) {
            if (i == 11) {
                odd();
            }
        } else if (ra - rd > 0) {
            if (i == 11) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rd + "%↑";
            }
        } else if (ra - rd < 0) {
            if (i == 11) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rd - ra + "%↓";
            }
        }
    }

}
function womanss() {
    // 取本地存储值
    let dates = getDates();
    if (dates.length >= 4) {
        // 第一个
        let cad = dates.length - 1;
        bb.children[0].innerHTML = dates[cad].dts;
        bb.children[1].innerHTML = dates[cad].cm;
        bb.children[2].innerHTML = dates[cad].kg;
        bb.children[3].innerHTML = dates[cad].num;
        // 第二个
        let cac = dates.length - 2;
        ab.children[0].innerHTML = dates[cac].dts;
        ab.children[1].innerHTML = dates[cac].cm;
        ab.children[2].innerHTML = dates[cac].kg;
        ab.children[3].innerHTML = dates[cac].num;
        // 第三个
        let cab = dates.length - 3;
        ae.children[0].innerHTML = dates[cab].dts;
        ae.children[1].innerHTML = dates[cab].cm;
        ae.children[2].innerHTML = dates[cab].kg;
        ae.children[3].innerHTML = dates[cab].num;
        // 第四个
        let caa = dates.length - 4;
        ah.children[0].innerHTML = dates[caa].dts;
        ah.children[1].innerHTML = dates[caa].cm;
        ah.children[2].innerHTML = dates[caa].kg;
        ah.children[3].innerHTML = dates[caa].num;
    }

    //时间变化
    let oa = bb.children[0].innerHTML;
    let ob = ab.children[0].innerHTML;
    let oc = ae.children[0].innerHTML;
    let od = ah.children[0].innerHTML;
    let oas = oa.split('.');
    let obs = ob.split('.');
    let ocs = oc.split('.');
    let ods = od.split('.');
    for (let i = 0; i < dad.length; i++) {
        if (i == 0) {
            if (oas[0] - obs[0] == 0) {
                // 一个月内
                if (oas[1] - obs[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - obs[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[0] - obs[0] + "天前";
                } else if (oas[1] - obs[1] == 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                }
                else if (oas[1] - obs[1] == 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                }
                else if (oas[1] - obs[1] == 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - obs[0] + "月前";
            }
        }
        if (i == 4) {
            if (oas[0] - ocs[0] == 0) {
                // 一个月内
                if (oas[1] - ocs[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - ocs[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[0] - ocs[0] + "天前";
                } else if (oas[1] - ocs[1] == 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                }
                else if (oas[1] - ocs[1] == 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                }
                else if (oas[1] - ocs[1] == 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - ocs[0] + "月前";
            }
        }
        if (i == 8) {
            if (oas[0] - ods[0] == 0) {
                // 一个月内
                if (oas[1] - ods[1] == 0) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1天内";
                } else if (oas[1] - ods[1] < 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = oas[0] - ods[0] + "天前";
                } else if (oas[1] - ods[1] == 7) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "1周前";
                }
                else if (oas[1] - ods[1] == 14) {
                    dad[i].style.color = "green";
                    dad[i].innerHTML = "2周前";
                }
                else if (oas[1] - ods[1] == 21) {
                    dad[i].style.color = "yellow";
                    dad[i].innerHTML = "3周前";
                }
            } else {
                //超过一个月
                dad[i].style.color = "red";
                dad[i].innerHTML = oas[0] - ods[0] + "月前";
            }
        }
    }

    // 身高变化 
    let pa = bb.children[1].innerHTML;
    let pb = ab.children[1].innerHTML;
    let pc = ae.children[1].innerHTML;
    let pd = ah.children[1].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function obb() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "black";
        }
        if (pa - pb == 0) {
            if (i == 1) {
                obb();
            }
        } else if (pa - pb > 0) {
            if (i == 1) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pb + "cm↑";
            }
        } else if (pa - pb < 0) {
            if (i == 1) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pb - pa + "cm↓";
            }
        }
        if (pa - pc == 0) {
            if (i == 5) {
                obb();
            }
        } else if (pa - pc > 0) {
            if (i == 5) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pc + "cm↑";
            }
        } else if (pa - pc < 0) {
            if (i == 5) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pc - pa + "cm↓";
            }
        }
        if (pa - pd == 0) {
            if (i == 9) {
                obb();
            }
        } else if (pa - pd > 0) {
            if (i == 9) {
                dad[i].style.color = "green";
                dad[i].innerHTML = pa - pd + "cm↑";
            }
        } else if (pa - pd < 0) {
            if (i == 9) {
                dad[i].style.color = "red";
                dad[i].innerHTML = pd - pa + "cm↓";
            }
        }
    }

    // 体重变化
    let da = bb.children[2].innerHTML;
    let db = ab.children[2].innerHTML;
    let dc = ae.children[2].innerHTML;
    let dd = ah.children[2].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function occ() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "block";
        }

        if (da - db == 0) {
            if (i == 2) {
                occ();
            }
        } else if (da - db > 0) {
            if (i == 2) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - db + "kg↑";
            }
        } else if (da - db < 0) {
            if (i == 2) {
                dad[i].style.color = "green";
                dad[i].innerHTML = db - da + "kg↓";
            }
        }
        if (da - dc == 0) {
            if (i == 6) {
                occ();
            }
        } else if (da - dc > 0) {
            if (i == 6) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - dc + "kg↑";
            }
        } else if (da - dc < 0) {
            if (i == 6) {
                dad[i].style.color = "green";
                dad[i].innerHTML = dc - da + "kg↓";
            }
        }
        if (da - dd == 0) {
            if (i == 10) {
                occ();
            }
        } else if (da - dd > 0) {
            if (i == 10) {
                dad[i].style.color = "red";
                dad[i].innerHTML = da - dd + "kg↑";
            }
        } else if (da - dd < 0) {
            if (i == 10) {
                dad[i].style.color = "green";
                dad[i].innerHTML = dd - da + "kg↓";
            }
        }
    }

    // 体脂率变化
    let ra = bb.children[3].innerHTML;
    let rb = ab.children[3].innerHTML;
    let rc = ae.children[3].innerHTML;
    let rd = ah.children[3].innerHTML;
    for (let i = 0; i < dad.length; i++) {
        function odd() {
            dad[i].innerHTML = "无变化";
            dad[i].style.color = "block";
        }
        if (ra - rb == 0) {
            if (i == 3) {
                odd();
            }
        } else if (ra - rb > 0) {
            if (i == 3) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rb + "%↑";
            }
        } else if (ra - rb < 0) {
            if (i == 3) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rb - ra + "%↓";
            }
        }
        if (ra - rc == 0) {
            if (i == 7) {
                odd();
            }
        } else if (ra - rc > 0) {
            if (i == 7) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rc + "%↑";
            }
        } else if (ra - rc < 0) {
            if (i == 7) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rc - ra + "%↓";
            }
        }
        if (ra - rd == 0) {
            if (i == 11) {
                odd();
            }
        } else if (ra - rd > 0) {
            if (i == 11) {
                dad[i].style.color = "red";
                dad[i].innerHTML = ra - rd + "%↑";
            }
        } else if (ra - rd < 0) {
            if (i == 11) {
                dad[i].style.color = "green";
                dad[i].innerHTML = rd - ra + "%↓";
            }
        }
    }
}
